const fs = require('fs');
const zlib = require('zlib');
const gzip = zlib.createGzip();

const readstream = fs.createReadStream('./note.txt'); // 创建流
const writestream = fs.createWriteStream('./note2.gzip'); //

readstream // 把 note.txt 文件流拿到
    .pipe(gzip) // 放在压缩包里
    .pipe(writestream); // 写入note2.txt 里面
